<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	allClose();
});

function allClose() {
	$('.showDiv').show();
	$('.updateDiv').hide();
	$('.showDiv .position_no').hide();
}

function openUpdate(review_no){
	allClose();
	
	var showDiv=$('#showDiv_'+review_no);
	var updateDiv=$('#updateDiv_'+review_no);
	
	updateDiv.find($('.position_no')).val(showDiv.find($('.position_no')).text());
	
	updateDiv.find($('.review_title')).val(showDiv.find($('.review_title')).text());
	updateDiv.find($('.review_pros')).val(showDiv.find($('.review_pros')).text());
	updateDiv.find($('.review_cons')).val(showDiv.find($('.review_cons')).text());
	updateDiv.find($('.review_way')).val(showDiv.find($('.review_way')).text());
	
	updateDiv.find($('.review_giveup[value='+showDiv.find($('.review_giveup')).text()+']')).prop('checked', true);
	updateDiv.find($('.review_gender[value='+showDiv.find($('.review_gender')).text()+']')).prop('checked', true);
	updateDiv.find($('.review_recommend[value='+showDiv.find($('.review_recommend')).text()+']')).prop('checked', true);
	updateDiv.find($('.review_score[value='+showDiv.find($('.review_score')).text()+']')).prop('checked', true);
	updateDiv.find($('.review_job[value='+showDiv.find($('.review_job')).text()+']')).prop('checked', true);
	updateDiv.find($('.review_professor[value='+showDiv.find($('.review_professor')).text()+']')).prop('checked', true);
	updateDiv.find($('.review_facility[value='+showDiv.find($('.review_facility')).text()+']')).prop('checked', true);
	updateDiv.find($('.review_scholarship[value='+showDiv.find($('.review_scholarship')).text()+']')).prop('checked', true);
	updateDiv.find($('.review_awareness[value='+showDiv.find($('.review_awareness')).text()+']')).prop('checked', true);
	
	showDiv.hide();
	updateDiv.show();
}

function delReview(review_no) {
	if(confirm("정말 삭제하시겠습니까?")){
		$.ajax({
			type:"post",
			url:"review.do",
			data:"command=deleteReview&&review_no="+review_no,
			
			success:function(data){			
				location.reload();
			}
		});
	}
}

function updateReview(review_no) {
	if(confirm("수정하면 진실/거짓 투표수가 초기화됩니다.\r\n정말 수정하시겠습니까?")){
		$('#updateForm_'+review_no).submit();
	}
}
</script>
</head>
<body>
<c:import url="my_header.jsp"/><p>
학과리뷰
<a href="member.do?command=myExam">입시정보</a>
<p>

<div>
	<c:forEach var="reviewReturn" items="${requestScope.reviewList.reviewlist}">
		<div>
			<div id="showDiv_${ reviewReturn.review.review_no }" class="showDiv">
				<div class="majorunit_name">${ reviewReturn.review.majorunit.univ.univ_name }
				${ reviewReturn.review.majorunit.college.college_name }
				${ reviewReturn.review.majorunit.faculty.faculty_name }
				${ reviewReturn.review.majorunit.major.major_name }</div>
				<div class="position_no">${ reviewReturn.review.position.position_no }</div>
				<div class="position_name">${ reviewReturn.review.position.position_name }</div>
				<div class="review_title">${ reviewReturn.review.review_title }</div>
				<div class="review_pros">${ reviewReturn.review.review_pros }</div>
				<div class="review_cons">${ reviewReturn.review.review_cons }</div>
				<div class="review_way">${ reviewReturn.review.review_way }</div>
				<div class="review_giveup">${ reviewReturn.review.review_giveup }</div>
				<div class="review_gender">${ reviewReturn.review.review_gender }</div>
				<div class="review_recommend">${ reviewReturn.review.review_recommend }</div>
				<div class="review_score">${ reviewReturn.review.review_score }</div>
				<div class="review_job">${ reviewReturn.review.review_job }</div>
				<div class="review_professor">${ reviewReturn.review.review_professor }</div>
				<div class="review_facility">${ reviewReturn.review.review_facility }</div>
				<div class="review_scholarship">${ reviewReturn.review.review_scholarship }</div>
				<div class="review_awareness">${ reviewReturn.review.review_awareness }</div>
				<div class="review_regdate">${ reviewReturn.review.review_regdate }</div>
				<div class="review_approval">
					<c:if test="${ reviewReturn.review.review_approval==-1 }">승인불가</c:if>
					<c:if test="${ reviewReturn.review.review_approval==0 }">승인대기</c:if>
					<c:if test="${ reviewReturn.review.review_approval==1 }">승인완료</c:if>
				</div>
				
				<a href="javascript:openUpdate('${ reviewReturn.review.review_no }')">수정</a>
				<a href="javascript:delReview('${ reviewReturn.review.review_no }')">삭제</a>
			</div>
			<div class="updateDiv" id="updateDiv_${ reviewReturn.review.review_no }">
				<form action="review.do" id="updateForm_${ reviewReturn.review.review_no }" method="post">
					<input type="hidden" name="command" value="updateReview">
					<input type="hidden" name="majorunit.majorunit_no" value="${ reviewReturn.review.majorunit.majorunit_no }">
					
					${ reviewReturn.review.majorunit.univ.univ_name }
					${ reviewReturn.review.majorunit.college.college_name }
					${ reviewReturn.review.majorunit.faculty.faculty_name }
					${ reviewReturn.review.majorunit.major.major_name }<p>
					
					<select name="position.position_no" class="position_no">
						<c:forEach var="position" items="${ requestScope.positionList }">
							<option value="${ position.position_no }">${ position.position_name }</option>
						</c:forEach>
					</select><p>
					
					제목<p>
					<textarea class="review_title" name="review_title" cols="40" rows="3"></textarea><p>
					장점<p>
					<textarea class="review_pros" name="review_pros" cols="40" rows="3"></textarea><p>
					단점<p>
					<textarea class="review_cons" name="review_cons" cols="40" rows="3"></textarea><p>
					졸업 후<p>
					<textarea class="review_way" name="review_way" cols="40" rows="3"></textarea><p>
					전공포기여부<p>
					<input type="radio" class="review_giveup" name="review_giveup" value="0">포기안함<p>
					<input type="radio" class="review_giveup" name="review_giveup" value="1">포기<p>
					남녀비율<p>
					<input type="radio" class="review_gender" name="review_gender" value="0">남 0 : 여 10
					<input type="radio" class="review_gender" name="review_gender" value="1">남 1 : 여 9
					<input type="radio" class="review_gender" name="review_gender" value="2">남 2 : 여 8
					<input type="radio" class="review_gender" name="review_gender" value="3">남 3 : 여 7
					<input type="radio" class="review_gender" name="review_gender" value="4">남 4 : 여 6
					<input type="radio" class="review_gender" name="review_gender" value="5">남 5 : 여 5
					<input type="radio" class="review_gender" name="review_gender" value="6">남 6 : 여 4
					<input type="radio" class="review_gender" name="review_gender" value="7">남 7 : 여 3
					<input type="radio" class="review_gender" name="review_gender" value="8">남 8 : 여 2
					<input type="radio" class="review_gender" name="review_gender" value="9">남 9 : 여 1
					<input type="radio" class="review_gender" name="review_gender" value="10">남 10 : 여 0<p>
					지인추천<p>
					<input type="radio" class="review_recommend" name="review_recommend" value="1">추천
					<input type="radio" class="review_recommend" name="review_recommend" value="0">추천안함<p>
					총점<p>
					<input type="radio" class="review_score" name="review_score" value="1">매우 낮음
					<input type="radio" class="review_score" name="review_score" value="2">낮음
					<input type="radio" class="review_score" name="review_score" value="3">보통
					<input type="radio" class="review_score" name="review_score" value="4">높음
					<input type="radio" class="review_score" name="review_score" value="5">매우 높음<p>
					취업 전망<p>
					<input type="radio" class="review_job" name="review_job" value="1">매우 낮음
					<input type="radio" class="review_job" name="review_job" value="2">낮음
					<input type="radio" class="review_job" name="review_job" value="3">보통
					<input type="radio" class="review_job" name="review_job" value="4">높음
					<input type="radio" class="review_job" name="review_job" value="5">매우 높음<p>
					교수진 및 강의<p>
					<input type="radio" class="review_professor" name="review_professor" value="1">매우 낮음
					<input type="radio" class="review_professor" name="review_professor" value="2">낮음
					<input type="radio" class="review_professor" name="review_professor" value="3">보통
					<input type="radio" class="review_professor" name="review_professor" value="4">높음
					<input type="radio" class="review_professor" name="review_professor" value="5">매우 높음<p>
					학교지원 및 시설<p>
					<input type="radio" class="review_facility" name="review_facility" value="1">매우 낮음
					<input type="radio" class="review_facility" name="review_facility" value="2">낮음
					<input type="radio" class="review_facility" name="review_facility" value="3">보통
					<input type="radio" class="review_facility" name="review_facility" value="4">높음
					<input type="radio" class="review_facility" name="review_facility" value="5">매우 높음<p>
					장학금<p>
					<input type="radio" class="review_scholarship" name="review_scholarship" value="1">매우 낮음
					<input type="radio" class="review_scholarship" name="review_scholarship" value="2">낮음
					<input type="radio" class="review_scholarship" name="review_scholarship" value="3">보통
					<input type="radio" class="review_scholarship" name="review_scholarship" value="4">높음
					<input type="radio" class="review_scholarship" name="review_scholarship" value="5">매우 높음<p>
					인지도 및 학연<p>
					<input type="radio" class="review_awareness" name="review_awareness" value="1">매우 낮음
					<input type="radio" class="review_awareness" name="review_awareness" value="2">낮음
					<input type="radio" class="review_awareness" name="review_awareness" value="3">보통
					<input type="radio" class="review_awareness" name="review_awareness" value="4">높음
					<input type="radio" class="review_awareness" name="review_awareness" value="5">매우 높음<p>
				</form>
				
				<a href="javascript:updateReview('${ reviewReturn.review.review_no }')">수정</a>
				<a href="javascript:allClose()">취소</a>
			</div>
		</div><br><br>
	</c:forEach>
</div>
<div>
	<c:set var="page" value="${requestScope.reviewList.pageManager}" />

	<c:if test="${page.currGroup==1}"><img alt="" src="../img/button/page_begin.gif"></c:if>
	<c:if test="${page.currGroup!=1}">
		<a href="member.do?command=${param.command}&&page=1"><img alt="" src="../img/button/page_begin.gif"></a>
	</c:if>

	<c:if test="${page.existOfPreviousGroup}">
		<a href="member.do?command=${param.command}&&page=${page.firstPageInCurrGroup-page.pagePerGroup}">
			<img alt="" src="../img/button/page_prev.gif"></a>
	</c:if>
	<c:if test="${!page.existOfPreviousGroup}"><img alt="" src="../img/button/page_prev.gif"></c:if>

	<c:forEach var="pageIndex" begin="${page.firstPageInCurrGroup}"
		end="${page.lastPageInCurrGroup}">
		<c:if test="${pageIndex==page.currPage}">&nbsp;<font color="#ff6d66">${pageIndex}</font>&nbsp;</c:if>
		<c:if test="${pageIndex!=page.currPage}">
			<a href="member.do?command=${param.command}&&page=${pageIndex}">&nbsp;<font color="#606060">${pageIndex}</font>&nbsp;</a>
		</c:if>
	</c:forEach>

	<c:if test="${page.existOfNextGroup}">
		<a href="member.do?command=${param.command}&&page=${page.lastPageInCurrGroup+1}">
			<img alt="" src="../img/button/page_next.gif"></a>
	</c:if>
	<c:if test="${!page.existOfNextGroup}"><img alt="" src="../img/button/page_next.gif"></c:if>

	<c:if test="${page.currGroup==page.totalGroup}"><img alt="" src="../img/button/page_end.gif"></c:if>
	<c:if test="${page.currGroup!=page.totalGroup}">
		<a href="member.do?command=${param.command}&&page=${page.totalPage}"><img alt="" src="../img/button/page_end.gif"></a>
	</c:if>
</div>


</body>
</html>